<?php

/*
 * Action
 * 
 * 5$
 * 
 * You may discard a Treasure. If you do, +3 Cards and +1 Action.
 * 
 */

class Stables extends Card implements iAction, iKingdom, iHinterlands {

    public function __construct() {
        parent::__construct("Stables", 5);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "You may discard a Treasure. If you do, +3 Cards and +1 Action.");
    }

    public function getDisplayName($quantity = 1) {
        if ($quantity == 1) {
            return "Stables";
        }
        return $quantity . " Stables";
    }

    public function play(Game $game, $isRealCard) {
        $playHand = $game->getPlayHand();
        $treasures = array();
        foreach ($playHand as $card) {
            if ($card instanceof iTreasure) {
                $treasures[] = $card;
            }
        }

        if (sizeof($treasures) > 0) {
            $treasures = getUniqueCards($treasures);
            $treasures[] = new Option(1, 'None');

            $output = MySocket::GetUserReply($game, Input_ChooseOne, $treasures, 1, 1, null, "Choose card to discard");
            $answer = $output[0];
            if ($answer != 'None') {
                $card = $game->moveCardFromPileToPile($answer, PlayHand, DiscardPile);
                ScreenDisplay::addScreenMessage($game, true, "discard " . nicePrint($card), " discards " . ScreenDisplay::$LMSG);

                $game->addActions(1);
                $drawed_cards = $game->drawCards(3);
                ScreenDisplay::addScreenMessage($game, false, ", get +1 action and draw " . nicePrint($drawed_cards), ", gets +1 action and draws " . sizeof($drawed_cards) . " cards");
            } else {
                ScreenDisplay::addScreenMessage($game, true, "discard nothing  ", " discards nothing");
            }
        } else {
            ScreenDisplay::addScreenMessage($game, true, "discard nothing  ", " discards nothing");
        }
    }

}